package com.ruoyi.eims.store.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.eims.store.domain.InboundPay;
import com.ruoyi.eims.store.service.IInboundPayService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 入库支付单管理Controller
 * 
 * @author hp
 * @date 2023-02-05
 */
@RestController
@RequestMapping("/inpay")
public class InboundPayController extends BaseController
{
    @Autowired
    private IInboundPayService inboundPayService;

    /**
     * 查询入库支付单管理列表
     */
    @RequiresPermissions("eims.store:inpay:list")
    @GetMapping("/list")
    public TableDataInfo list(InboundPay inboundPay)
    {
        startPage();
        List<InboundPay> list = inboundPayService.selectInboundPayList(inboundPay);
        return getDataTable(list);
    }

    /**
     * 导出入库支付单管理列表
     */
    @RequiresPermissions("eims.store:inpay:export")
    @Log(title = "入库支付单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InboundPay inboundPay)
    {
        List<InboundPay> list = inboundPayService.selectInboundPayList(inboundPay);
        ExcelUtil<InboundPay> util = new ExcelUtil<InboundPay>(InboundPay.class);
        util.exportExcel(response, list, "入库支付单管理数据");
    }

    /**
     * 获取入库支付单管理详细信息
     */
    @RequiresPermissions("eims.store:inpay:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(inboundPayService.selectInboundPayById(id));
    }

    /**
     * 新增入库支付单管理
     */
    @RequiresPermissions("eims.store:inpay:add")
    @Log(title = "入库支付单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InboundPay inboundPay)
    {
        return toAjax(inboundPayService.insertInboundPay(inboundPay));
    }

    /**
     * 修改入库支付单管理
     */
    @RequiresPermissions("eims.store:inpay:edit")
    @Log(title = "入库支付单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InboundPay inboundPay)
    {
        return toAjax(inboundPayService.updateInboundPay(inboundPay));
    }

    /**
     * 删除入库支付单管理
     */
    @RequiresPermissions("eims.store:inpay:remove")
    @Log(title = "入库支付单管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(inboundPayService.deleteInboundPayByIds(ids));
    }
}
